﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>AutoComplete</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" /><link href="../demo.css" rel="stylesheet" type="text/css" />

    
    <script src="../../scripts/boot.js" type="text/javascript"></script>
    
    
</head>
<body>
   
<input id="tbl1" name="tb" class="mini-autocomplete" required="true" style="width:200px;"
    valueField="id" textField="text"   valueFromSelect="true"
        value="cn" text="中国" 
        remote="false"
/>

   <br /><br />
    <input type="button" value="setValue" onclick="setValue()"/>
    <input type="button" value="getValue" onclick="getValue()"/>    
    <input type="button" value="disable" onclick="disable()"/>
    <input type="button" value="enable" onclick="enable()"/>


    <script type="text/javascript">
        mini.parse();

        var t = mini.get("tbl1");
        var data = [
            { "id": "usa", "text": "美国" },
            { "id": "cn", "text": "中国" },
            { "id": "jp", "text": "日本", enabled: false },
            { "id": "en", "text": "英国" },
            { "id": "de", "text": "德国" },
            { "id": "fr", "text": "法国" },
	        { "id": "ca", "text": "加拿大" },
	        { "id": "at", "text": "奥地利" },
	        { "id": "ch", "text": "瑞士" }
        ];

        t.setData(data);
        
        function setValue() {
            var t = mini.get("tbl1");
            
            
            t.setValue("1");
            t.setText("张三");
        }
        function getValue() {
            var t = mini.get("tbl1");
            alert(t.getValue());
        }
        function enable() {
            var t = mini.get("tbl1");
            t.enable();
        }
        function disable() {
            var t = mini.get("tbl1");

            t.disable();
        }

        function onValueChanged(e) {
            
            var item = e.selected;
            if (item) { 
                alert(item.id + ":" + item.text);   //获取选中行更多属性
            }
        }

    </script>
</body>
</html>